/*
 * @Author: 刘润泽
 * @Date: 2023-03-14 19:16:01
 * @LastEditors: 刘润泽
 * @LastEditTime: 2023-03-14 19:50:31
 * @Description: 
 */
/*
* @Author: 刘润泽
* @Date: 2023-03-12 21:45:20
 * @LastEditors: 刘润泽
 * @LastEditTime: 2023-03-14 19:50:25
* @Description:
*/
package server.business.converter.Converter;

import org.springframework.stereotype.Component;

import com.alibaba.excel.converters.Converter;
import com.alibaba.excel.enums.CellDataTypeEnum;
import com.alibaba.excel.metadata.CellData;
import com.alibaba.excel.metadata.GlobalConfiguration;
import com.alibaba.excel.metadata.property.ExcelContentProperty;

@Component
public class BloodSizeConverter implements Converter<Integer> {

	@Override
	public Class<String> supportJavaTypeKey() {
		return String.class;
	}

	@Override
	public CellDataTypeEnum supportExcelTypeKey() {
		return CellDataTypeEnum.STRING;
	}

	@Override
	public CellData<String> convertToExcelData(Integer value, ExcelContentProperty excelContentProperty,
			GlobalConfiguration globalConfiguration) throws Exception {
		if (value == null) {
			return new CellData<>("");
		} else if (value == 1) {
			return new CellData<>("100ml");
		} else if (value == 2) {
			return new CellData<>("200ml");
		} else if (value == 3) {
			return new CellData<>("400ml");
		} else if (value == 4) {
			return new CellData<>("800ml");
		} else {
			return new CellData<>("错误数据");
		}
	}

	@Override
	public Integer convertToJavaData(CellData arg0, ExcelContentProperty arg1, GlobalConfiguration arg2)
			throws Exception {
		throw new UnsupportedOperationException("Unimplemented method 'convertToJavaData'");
	}

}
